package com.lly.songhigh.fragment;

import android.support.v4.app.Fragment;
import android.util.SparseArray;

/**
 * Created by dllo on 15/10/24.
 */
public class SearchResultFragmentFactory {

    private static SparseArray<Fragment> fragmentSparseArray = new SparseArray<>();
    public static Fragment creatFragment(int position){

        Fragment fg = fragmentSparseArray.get(position);
        if (fg == null) {
            switch (position){
                case 0:
                    fg = new SearchSingleSongFragment();
                    break;
                case 1:
                    fg = new SearchSingerFragment();
                    break;
                case 2:
                    fg = new SearchSpecialAlbumFragment();
                    break;
                case 3:
                    fg = new SearchMVFragment();
                    break;
                default:
                    fg = new SearchSingleSongFragment();
                    break;
            }
            fragmentSparseArray.put(position, fg);
        }
        return fg;
    }
}
